package com.springboot.tools.filter;

import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;



public class FirstFilter implements Filter {

	@Override
	public void destroy() {
		System.out.println("destroy-=----FirstFilter");

	}

	@Override
	public void doFilter(ServletRequest arg0, ServletResponse arg1,
						 FilterChain arg2) throws IOException, ServletException {
		System.out.println("doFilter---start");
		HttpServletRequest request= (HttpServletRequest)arg0;
		HttpServletResponse reponse=(HttpServletResponse)arg1;

		reponse.sendRedirect(request.getContextPath()+"/error.jsp");

		System.out.println("doFilter---end");
	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
		System.out.println("init---------------");
	}
}
